package com.meisupic.copyright.service.impl;

import com.meisupic.copyright.domain.po.CopyrightHelp;
import com.meisupic.copyright.domain.vo.QuestionAnswerVo;
import com.meisupic.copyright.repo.CopyrightHelpRepo;
import com.meisupic.copyright.service.ICopyrightHelpService;
import com.meisupic.copyright.util.BeanMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CopyrightHelpServiceImpl implements ICopyrightHelpService {

  @Autowired
  CopyrightHelpRepo copyrightHelpRepo;

  @Override
  public List<QuestionAnswerVo> findAllQuestions() {
    List<CopyrightHelp> questionAnswers = copyrightHelpRepo.findAll();
    return BeanMapper.mapList(questionAnswers, QuestionAnswerVo.class);
  }

  @Override
  public QuestionAnswerVo findQuestionById(Long id) {
    CopyrightHelp questionAnswer = copyrightHelpRepo.findOne(id);
    if (questionAnswer != null) {
      QuestionAnswerVo questionAnswerVo = BeanMapper.map(questionAnswer, QuestionAnswerVo.class);
      return questionAnswerVo;
    }
    return null;
  }
}
